package main

import (
	"flag"
	"gitee.com/visons/gopkg/logger"
	"os"
	"os/signal"
	"syscall"
	"web-model/config"
	"web-model/router"
)

func main() {
	//加载配置文件
	var configPath = flag.String("c", "conf/conf.toml", "file full path")
	conf := config.InitConfig(*configPath)
	//svc.ServiceInit()
	//log.Infof("game start............")
	//gin开始运行
	router.NewRouter().Run(conf.ListenAddr)

	// 系统退出处理 signal handler
	c := make(chan os.Signal, 1)
	signal.Notify(c, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
	for {
		s := <-c
		logger.Info("system get a signal %s", s.String())
		switch s {
		case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
			logger.Info("system exit")
			return
		default:
			return
		}
	}
}
